<?php
class redirector{
protected $uri;
protected $base = false;
protected $urirestictions = array('\\','.','#',' ',"-");
protected $uricleaned;
protected $uricleanedexploded;
protected $redirectionbase = '..';
protected $redirectionfile = 'index.php';
protected $redirectionerrorpath = '404.php';
function __construct(){
$this->uri=$_SERVER['REQUEST_URI'];
}
function setUri($uri){
$this->uri=$uri;
}
function setBase($Base){
$this->base=$Base;
}
function setSpecialCleaningParams($urirestictions){
$this->urirestictions=$urirestictions;
}
function cleanuri(){
$urirestictions= $this->urirestictions;
$this->uricleaned = str_replace($urirestictions, '', $this->uri);
}
function explodeuri(){
$this->uricleanedexploded = explode('/', $this->uricleaned);
}
function showUri(){
return $this->uri;
}
function showUriExploded(){
return $this->uricleanedexploded;
}
function generate(){
$this->cleanuri();
$this->explodeuri();
}
function get($int){
$int++;
if(isset($this->uricleanedexploded[$int]))
return $this->uricleanedexploded[$int];
else return false;
}
function setRedirectionbase($redirectionbase){
$this->redirectionbase=$redirectionbase;
}
function setRedirectionfile($redirectionfile){
$this->redirectionfile=$redirectionfile;
}
function route(){
$filepath = $this->redirectionbase.'/'.$this->redirectionfile;
if(file_exists($filepath) == true)
include $filepath;
else 
include $this->redirectionerrorpath;
}
}